www.gusucode.com > XerCMS 携云PHP企业建站程序 v2015PHP源码程序 > XerCMS 携云PHP企业建站程序 v2015/XerCMS_v20150724/XerCMS_v20150724/XerCMS/Modules/extends/index.php

    <?php
/**
 * @name     XERCMS
 * @author   Arno <XerCMS@163.com> [QQ:1328013]
 * @version  1.0.0
 * @link     http://www.XerCMS.com
 */
 
!defined('XERCMS') && exit('Access Denied');

class XerCMS_MODULE_index
{  
     function guestbook() {
          include_once(tpl('extends/guestbook.htm'));
     }
     
     function vote() {
          setJson();
          $vid = (int)g('vid');$oid = (int)g('oid');
          $vote = DB::result('SELECT * FROM xercms_vote WHERE id = \''.$vid.'\'');
          if(isset($vote['title'])) {
               if($vote['stime'] < X::$G['time']) {
                    showtips('投票尚未开始!');
               } else if ($vote['etime'] < X::$G['time']) {
                    showtips('投票已经结束!');
               } else if (!empty($vote['limit']) && $vote['over'] <= 0) {
                    showtips('投票人数已经足够!');
               } else {
                    $oid = DB::result_first('SELECT count(*) FROM xercms_vote_options WHERE oid = '.$oid.' AND vid = \''.$vid.'\'');
                    if(!$oid) {
                         showtips('没有该投票选项!');
                    }
                    if(empty($vote['number'])) {
                         $count = DB::result_first('SELECT count(*) FROM xercms_vote_log WHERE uid = '.X::$G['uid'].' AND vid = \''.$vid.'\'  AND oid = \''.$oid.'\'');
                         if($count > 0) {
                              showtips('已投票!');
                         }                                           
                    } else {
                         $count = DB::result_first('SELECT count(*) FROM xercms_vote_log WHERE uid = '.X::$G['uid'].' AND vid = \''.$vid.'\'');
                         if($count >= $vote['number']) {
                              showtips('已超过每人投票数!');
                         }
                    }
                    if($count == 0) {
                         DB::add('xercms_vote',array('over'=>-1),array('vid'=>$vid));
                    }
                    DB::insert('xercms_vote_log',array('uid'=>X::$G['uid'],'vid'=>$vid,'oid'=>$oid,'time'=>X::$G['time'],'ip'=>X::$G['ip']));
                    DB::add('xercms_vote_log',array('total'=>1),array('vid'=>$vid,'oid'=>$oid));
               }
          }
     }
    
     function desktop() {
          header('Content-Type: application/force-download');
          header('Content-Disposition: attachment; filename="'.X::$G['sitename'].'.url"');
          exit("[InternetShortcut]\r\nURL=http://".X::$G['domain'].X::$G['urlpath']."\r\nIDList=[{000214A0-0000-0000-C000-000000000046}]"); 
     }
    
     function guestbookSubmit() {
          if(!X::$G['uid'] && (!isset(X::$CONFIG['guestbook']) || X::$CONFIG['guestbook'] == 'member')) {
               showtips('login',X::$G['urlpath'].'index.php?m=member&a=login');
          }

          $post = p('guestbook');

          if (empty($post['content'])) {
               showtips('guestbook_help_content',url('guestbook'));
          } else {
               if(empty($post['qq']) && empty($post['email']) && empty($post['tel'])) {
                    showtips('guestbook_help_contact',url('guestbook'));
               }
               $guestbook = DB::result('SELECT time FROM xercms_guestbook WHERE ip = \''.X::$G['ip'].'\' ORDER BY time DESC LIMIT 1');
               if(isset($guestbook['time']) && $guestbook['time'] + 60 > X::$G['time']) {
                    showtips('guestbook_time_limit',url('guestbook'));
               }
               $guestbook = array();
               $guestbook['name'] = htmlchars($post['name']);
               $guestbook['qq'] = htmlchars($post['qq']);
               $guestbook['email'] = htmlchars($post['email']);
               $guestbook['tel'] = htmlchars($post['tel']);
               $guestbook['content'] = htmlchars($post['content']);
               $guestbook['uid'] = X::$G['uid'];
               $guestbook['ip'] = X::$G['ip'];
               $guestbook['time'] = X::$G['time'];
               DB::insert('xercms_guestbook',$guestbook);
               showtips('guestbook_finish',url('guestbook'));
          }
     }   
    
     function announce() {
          $id = int1(g('id'));
          DB::add('xercms_announce',array('hits'=>1),array('id'=>$id));
          $announce = DB::result('SELECT a.*,m.nick FROM xercms_announce a LEFT JOIN xercms_member_profile m ON m.uid = a.uid WHERE a.id = \''.$id.'\'');
          //print_R($announce);
          include_once(tpl('extends/announce.htm'));
     }
    
     function special() {
          $id = (int)g('id');
          if(empty($id)) {
               $page = int1(g('page'));$class = (int)g('class');
               $specials = DB::fetch_all('SELECT * FROM xercms_special a LEFT JOIN xercms_special_count c ON c.sid = a.id '.(empty($class) ? '' : ' WHERE class = \''.$class.'\'').' ORDER BY a.ctime DESC LIMIT '.(($page-1)*30).',30');
               $classes = DB::fetch_all('SELECT c.name,c.id as class FROM xercms_special_class c WHERE c.parent = 0');
               include_once(tpl('special/xercms.htm'));
               return;  
          }
          
          $special = DB::result('SELECT * FROM xercms_special a LEFT JOIN xercms_special_count c ON c.sid = a.id WHERE a.id = \''.$id.'\'');
          if(isset($special['title']) === false) {
               showtips('抱歉,不存在此专题',X::$G['urlpath'].'?m=extends&a=special');
          }
          X::$G['subtitle'] = $special['title'];
          DB::add('xercms_special_count',array('hits'=>1),array('sid'=>$id));
          $cp = int1(g('cp'));
          $comment_total = DB::count('xercms_special_comment',array('sid'=>$id,'stamp'=>1));
          if($special['comment']) {
               $comments = DB::fetch_all('SELECT c.*,p.avatar,p.nick FROM xercms_special_comment c LEFT JOIN xercms_member_profile p ON p.uid = c.uid WHERE c.stamp = 1 AND c.sid = \''.$id.'\' LIMIT '.(($cp-1)*20).',20');
          } else $comments = array();
          $comment_total = ceil($comment_total/15);
          $multicomment = multi($comment_total,$cp);
          $detail = &$special;
          include_once(tpl($special['template']));    
     }
}
?>